<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片自适应一个盒子</title>
</head>
<style>
.box{
    width: 800px;
    height: 800px;
    border: 1px solid #f60;
    position: relative;
}
.box img{
    width: 100%;
    height: 100%;
    position: absolute;
    /* 裁剪铺满 */
    object-fit:cover;
}
</style>
<body>
    <div class="box">
        <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fnimg.ws.126.net%2F%3Furl%3Dhttp%253A%252F%252Fdingyue.ws.126.net%252F2021%252F0513%252F0c47edcbj00qt0mf5002nc000dw00m8c.jpg%26thumbnail%3D650x2147483647%26quality%3D80%26type%3Djpg&refer=http%3A%2F%2Fnimg.ws.126.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1633793121&t=0ee51fc74184c7587a480ffd2e80024d" alt="">
    </div>
</body>
</html>